home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / utils / shellsort / shellsort.asm.readme < prev   
Text File  |  1980-01-03  |  3KB  |  70 lines

  1. today was 3.10.1993.
  2.  
  3. This is my first public appearance, and I don't think it's the last.
  4. I hope someone would find this program useable.
  5. If you call program with option everything would be obviously.
  6.  
  7. Part of this text you can find in source file.
  8.  
  9. This program is based on shellsort, best known sorting algorithm as I know.
  10. If anybody knows better algorithm, let me know.
  11. Here is source in C:
  12.  
  13. void shellsort(char *p[],short n)
  14. /* p is array of pointers to char strings(ending with '\0')
  15.    n is no. of elements (lines) */
  16. {    short    range,i,j;
  17.     char    *aid;
  18.     for(range=n/2;range>0;range/=2)
  19.     {    for(i=range;i<n;i++)
  20.             for(j=i-range;j>=0 && strcmp(p[j],p[j+range])>0;j-=range)
  21.             {    aid=p[j];
  22.                 p[j]=p[j+range];
  23.                 p[j+range]=aid;
  24.             }
  25.     }
  26. }
  27. Meaning is that you divide field of strings on two, and compare two elements
  28. with first range n/2, and if you find some to change do it and look behind
  29. is there maybe another element to change. When i and j loops finish, make
  30. new range, now it is n/4 and so on. Mathematicaly i don't know how many
  31. passes through array has to be done but it is fastest as I know.
  32.  
  33. First I make necessary house works and then read input file. I read it twice.
  34. Why? First, to read no. of lines and second time to read lengths of lines
  35. because then I can make proper allocations (this reads depend on option).
  36. Then I make sort and finally write to output file and deallocate memory.
  37. I know there is double use  of code, but I want it to be fastest and instructions
  38. in all loops are one word long. I tried as much as I could to do work in regs
  39. also to be faster. It is up to you to judge.
  40.  
  41. Personally, I tested program a lot of times with different files. Biggest file
  42. as I remember, was about 500k and sort was done good. Sometimes there can be
  43. found 1 trash byte at the end of the file. Sort is case sensitive and in my
  44. next versions I will put case insensitive sort, but it slows down sorting
  45. and I'll try to make it as fast as I can. If you know good algorithm and if
  46. that wouldn't be hard for you, contact me.
  47. Finally, speed.
  48. This program is 10 (TEN) times faster then sort you have in Workbench.
  49. This is on A1200. I have it. I didn't test it on A500. You may try.
  50. So, use it if you like it.
  51. This program is public domain, of course.
  52. I would like you people to contact me to exchange knowlege. Come on!
  53. I am mostly interested in SYSTEM programming.
  54. Don't be lazy.
  55.  
  56. My address:
  57.  
  58. Herendic Drazen
  59. Ul. 26. lipanj 9
  60. 43240 Cazma
  61. CROATIA
  62.  
  63.  
  64. You can send E-mail on my friend's address:
  65.  
  66.    korzi@branka.zems.etf.hr
  67.  
  68. If you send there, note for Drazen Herendic.
  69.  
  70.